module.exports = {
    publicPath: './',
    devServer: {
        open: true, //启动项目后自动开启浏览器
    },
    chainWebpack: (config) => {
        //修改文件引入自定义路径
        config.resolve.alias
            .set('@', resolve('src'))
    },
    productionSourceMap: false,
    chainWebpack(config) {
        config
            .optimization.splitChunks({
                chunks: 'all',
                cacheGroups: {
                    libs: {
                        name: 'chunk-libs',
                        test: /[\\/]node_modules[\\/]/,
                        priority: 10,
                        chunks: 'initial' //只打包初始时依赖的第三方
                    },
                    elementUI: {
                        name: 'chunk-elementUI', //单独将elementUI拆包
                        priority: 20, //权重必须大于libs和app，否则将打包进libs或app中
                        test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // 为了适配cnpm
                    },
                    echarts: {
                        name: 'chunk-echarts',
                        priority: 20, //权重必须大于libs和app，否则将打包进libs或app中
                        test: /[\\/]node_modules[\\/]_?echarts(.*)/ // 为了适配cnpm
                    },
                    wangeditor: {
                        name: 'chunk-wangeditor',
                        priority: 20, //权重必须大于libs和app，否则将打包进libs或app中
                        test: /[\\/]node_modules[\\/]_?wangeditor(.*)/ // 为了适配cnpm
                    }
                }
            })
    }
}